package br.com.gaspar.tm.mb;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import br.com.gaspar.framework.visao.jsf.ManagedBeanBase;
import br.com.gaspar.tm.bo.iface.IProjetoBO;
import br.com.gaspar.tm.entidade.Usuario;
import br.com.gaspar.utils.exception.BaseException;

@ManagedBean(name="UsuarioMB")
@ViewScoped
public class UsuarioMB extends ManagedBeanBase<Usuario> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@EJB
	private IProjetoBO<Usuario> bo;
	
	@Override
	protected IProjetoBO<Usuario> getFachada() {
		return bo;
	}
	
	@PostConstruct
	@Override
	public void iniciar() {
		/*HttpSession session = (HttpSession) 
				FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		
		String usuario = (String) session.getAttribute("usuario");
		if(usuario.equals("gaspar")){
			entidade = new Usuario();
			super.iniciar();
		}*/
		entidade = new Usuario();
		super.iniciar();
	}
	
	@Override
	protected void criarAntes() throws BaseException {
		entidade = new Usuario();
		super.criarAntes();
	}
	
	/*@Override
	public String criar() {
		HttpSession session = (HttpSession) 
				FacesContext.getCurrentInstance().getExternalContext().getSession(false);
		
		String usuario = (String) session.getAttribute("usuario");
		if(usuario.equals("gaspar")){
			return super.criar();
		}
		return "/socio/listar.jsf";
	}*/
}
